<?php use_helper('Number') ?>
<?php use_helper('Javascript') ?>

<?php /* @var $product Product */ ?>

<div class="category_title">
    <?php if( $categorySelected ): ?>
        <?php echo $categorySelected->getName() ?>
    <?php else: ?>
        <?php echo __('New products') ?>
    <?php endif; ?>
</div>

<!--
<div class="path">
    <?php echo link_to(
                    __('products')
                    , 'product'
                 ) ?>
    <?php if( !empty( $categories ) ): ?>
        <?php foreach ($categories as $category): ?> 
        	<?php echo image_tag(
                        'arrow.gif'
                        , array(
                            'border' => '0'
                            , 'alt' => ''
                        )
                    ) ?>
            <?php echo link_to(
                            $category->getName()
                        ) ?> 
        <?php endforeach; ?>
     <?php endif; ?>
</div>
-->

<div class="products">

<?php if( $pager->getNbResults() > 0 ): ?>

    <?php foreach( $pager->getResults() as $product ): ?>
            <?php include_partial(
                        'product/product'
                        , array(
                            'product' => $product
                        )); ?>
    <?php endforeach; ?>

<?php else: ?>

    <?php echo __('No products') ?>

<?php endif; ?>

</div>
<?php if ($pager->haveToPaginate()): ?>
    <div class="paging">
        <div class="paging_link">
            <?php echo link_to(
                    '&laquo;'
                    , 'product/list?p=' . $pager->getFirstPage() . '&id=' . $categoryId
                ) ?>
        </div>
        <div class="paging_link">
             <?php echo link_to(
                    '&lsaquo;'
                    , 'product/list?p='.$pager->getPreviousPage() . '&id=' . $categoryId
                ) ?>
        </div>
            <?php $links = $pager->getLinks(); 
            foreach ($links as $page): ?>
                <?php echo ($page == $pager->getPage()) ? '<div class="paging_current">' . $page . '</div>' : '<div class="paging_link">' . link_to($page, 'product/list?p='.$page. '&id=' . $categoryId) . '</div>' ?>
                <?php if ($page != $pager->getCurrentMaxLink()): ?>
                <?php endif; ?>
            <?php endforeach; ?>
        <div class="paging_link">
            <?php echo link_to(
                        '&rsaquo;'
                        , 'product/list?p='.$pager->getNextPage() . '&id=' . $categoryId
                    ) ?>
        </div>
        <div class="paging_link">
            <?php echo link_to(
                        '&raquo;'
                        , 'product/list?p='.$pager->getLastPage() . '&id=' . $categoryId
                    ) ?>
        </div>
    </div>
<?php endif ?>
